/**
 * @author 陈泰来
 * @version V1.0
 * @Project echo-java-base
 * @Title String、StringBuilder、StringBuffer
 * @Description *
 * @Package base.stringbuilderbuffer
 * @date 2021/3/23 4:00 下午
 * @Copyright:学如逆水行舟，不进则退 .
 */
package base.stringbuilderbuffer;

import java.util.concurrent.CyclicBarrier;

public class StringBuilderAndBuffer {
    public static void main(String[] args) {
//        Passing 'null' argument to parameter annotated as @NotNull
//        StringBuffer stringBuffer = new StringBuffer(null); //如此声明会导致空指针，因为源码中获取了 构造参数的length
        //测试 String 先赋值 哈哈 再赋值 呵呵，对象引用变化
        String a = "哈哈";

        System.out.printf("前者：%s \n", a.hashCode());

        a = "呵呵";

        System.out.printf("后者: %s \n", a.hashCode());

        a = "哈哈";

        System.out.printf("最后: %s \n", a.hashCode());

        StringBuilder sb = new StringBuilder();
        sb.append("1");
        System.out.printf("StringBuilder连续改变值后的hashCode %s \n",sb.hashCode());
        sb.append("2");
        System.out.printf("StringBuilder连续改变值后的hashCode %s  \n",sb.hashCode());
        sb.append("3");
        System.out.printf("StringBuilder连续改变值后的hashCode %s  \n",sb.hashCode());
        sb.append("4");
        System.out.printf("StringBuilder连续改变值后的hashCode %s  \n",sb.hashCode());
        sb.append("5");
        System.out.printf("StringBuilder连续改变值后的hashCode %s  \n",sb.hashCode());


    }
}
